//
//  VRPushSuccessView.swift
//  VoiceRoom
//
//  Created by Rui on 2024/3/16.
//

import UIKit
import SwiftEntryKit

class VRPushSuccessView: UIView, SAAnimationDelegate, SAAnimationProtocol {

    func animationContainerViewSize() -> CGSize {
        CGSize(width: .screenWidth - 30, height: 260)
    }
    
    func animationContainerViewStyle() -> SAAnimationViewStyle {
        .center
    }
    
    func animationContainerScreenInteraction() -> EKAttributes.UserInteraction {
        .init()
    }
    
    private lazy var titleLabel = c_make_ex(UILabel.self)
        .color(.white).font(18.font_bold).alignment(.center)
        .text("Successfully！").end()
    private lazy var contentLabel = c_make_ex(UILabel.self)
        .color(.white).font(16.font_medium).alignment(.center)
        .text("Congratulations on your successful publication. We will review your content. After passing the review, the content will be displayed on the homepage and other places.")
        .line(0).end()
    private lazy var okButton = c_make_ex(UIButton.self)
        .color(.black).font(18.font_bold).corner(25)
        .text("OK").bgColor("#FFFC00").end()
    
    var dismissBlock: (() -> Void)?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        backgroundColor = "#1F1E18".toColor
        self.fj.corner(20, corners: .allCorner)
        
        subviews{
            titleLabel
            contentLabel
            okButton
        }
        
        titleLabel.top(20).centerHorizontally()
        contentLabel.leading(15).trailing(15).top(60)
        okButton.width(300).height(50).bottom(20).centerHorizontally()
        
        okButton.addTarget(self, action: #selector(clickOKButton), for: .touchUpInside)
    }
    
    @objc private func clickOKButton(){
        saAnimate.animation(dismiss: self){
            self.dismissBlock?()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
